<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * Description of BarraFerramentas
 *
 * @author alan
 */
class BarraFerramentas {
    public static $acao;
    public static $script;
    public static function addAcao($operacao, $id, $script='') {
        self::$acao[$id]= $operacao;
        if($script){
            self::$script[$id]= $script;
        } else {
            self::$script[$id]=  "".
                                "$('#{$id}').click(function(){
                                op = $('#{$id}').val();
                                $('#op').val(op);
                                $('#VListaCrud').submit();
                                });";
        }
    }
    public static function getBarraFerramentas() {
        if(!empty (self::$acao)){
            $bt = "";
            $botsId = array();
            if(self::$acao) {
                foreach(self::$acao as $id => $op){
                    $botsId[] = $id;
                    $bt .= "\t\t<li><input type='button' id='$id' value='$op' class='Icone Acao'></li>\n";
                }
            }

            $scriptIni =
            "
            <script type='text/javascript'>
                $('document').ready(function(){
            ";

            $onclick = "";
            foreach(self::$script as $id => $script){
                $onclick .= $script;
            }

            $scriptFim =
            "
                });
            </script>
            ";

            $script = $scriptIni.$onclick.$scriptFim;

            $html = "
                <div id='acoes'>
                    <div id='acoesBordaE'></div>
                    <div id='menuAcoes'>
                        <ul>
            {$bt}
                        </ul>
                    </div>
                    <div id='acoesBordaD'></div>
                </div>
        ";
            return $script.$html;
        }
    }
}
//
//BarraFerramentas::addAcao('novo', 'acaoAdd');
//BarraFerramentas::addAcao('delete', 'acaoDel');
//echo BarraFerramentas::getBarraFerramentas();
?>